<?php
/**
 * Pipahr
 *
 * @author Randy Zhao
 * @copyright 2013 pipahr.com
 */
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();

if (isDevMode()) {
   OCP\Util::addStyle('interview', 'interview');
   OCP\Util::addScript('interview', 'jobtest');
} else {
   OCP\Util::addStyle('static', 'interview');
   OCP\Util::addScript('static', 'apps/interview.jobtest.min');
}

$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");

?>

<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('interview/js', 'interview.php'));?>"></script>

<div class="container sticky_element">
   <div class="row-fluid">
      <div class="span12">
         <div class="company_qes_fixed clearfix">
            <? echo $_['basicInfo']->comp_name ? $_['basicInfo']->comp_name : ''?>-<? echo $_['basicInfo']->job_title ? $_['basicInfo']->job_title : ''?>职位线上笔试<br/>
            <span id="sheet_info" data="{'total_time':'<?=$_['baseExamInfo']->totaltime?>'}">(线上笔试共<?=$_['baseExamInfo']->count?>题,笔试时间<?=$_['baseExamInfo']->totaltime?>分钟)</span>
            <div class="test_timetip" id="timeleft"></div>
         </div>
      </div>
   </div>
</div>

<div class="row-fluid hr_oneconn_margin">
   <div class="span12 oneconn_box">
      <div class="lgrg_form">
         <div class="hr_teststep hr_teststep_nomargin" style="width:95%; margin:auto;">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
               <tr>
                  <td width="" class="medium test_ok"><span class="teststep_1"><i></i>核对身份</span></td>
                  <td width="22" class="arrow_blue_blue"></td>
                  <td width="" class="medium test_ok"><span class="teststep_2"><i></i>完善信息</span></td>
                  <?php if ($_['isPaperSet'] && $_['isInviteToken']) :?>
                  <td width="22" class="arrow_blue_blue"></td>
                  <td width="" class="medium test_ok"><span class="teststep_3"><i></i>线上笔试</span></td>
                  <?php endif;?>
                  <td width="22" class="arrow_blue_grey"></td>
                  <td width="" class="medium"><span class="teststep_4"><i></i>完成&nbsp;&nbsp;&nbsp;</span></td>
               </tr>
            </table>
         </div>
         <form action="<?php echo OC_Helper::linkToRoute("interview_postexam");?>" method="post" name="examform" id="examform">
         <div id="exam_container" class="exam_container">
         <?php foreach ($_['examPaper'] as $k => $v):?>
         <?php
         if (!is_int($k))
            continue;
         $op_label = array('A','B','C','D','E','F','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
         switch ($v->type) {
            case 'singleanswer':
               ?>
               <div class="test_questionbox">
                  <h6><?=$k+1?>. <? echo $v->question_img ? "<img src='".$v->question_img."'>" : $v->question;?></h6>
                  <div class="test_question_select normal">
                     <?php foreach ($v->answer as $key => $choice):?>
                     <label class="radio">
                        <input type="radio" class="each_answer" name="<?=$v->questionid?>" value="<?=$key+1?>"/>
                        <?=$op_label[$key]?>. <?php echo htmlspecialchars($choice->choice);?>
                     </label>
                     <?php endforeach;?>
                  </div>
               </div>
               <?php
               break;
            case 'multipleanswer':
               ?>
               <div class="test_questionbox">
                  <h6><?=$k+1?>. <? echo $v->question_img ? "<img src='".$v->question_img."'>" : $v->question;?></h6>
                  <div class="test_question_select normal">
                     <?php foreach ($v->answer as $key => $choice):?>
                     <label class="checkbox">
                        <input type="checkbox" class="each_answer" name="<?=$v->questionid?>" value="<?=$key+1?>"/>
                        <?=$op_label[$key]?>. <?php echo htmlspecialchars($choice->choice);?>
                     </label>
                     <?php endforeach;?>
                  </div>
               </div>
               <?php
               break;
            case 'freeinput':
               ?>
               <div class="test_questionbox">
                  <h6><?=$k+1?>. <? echo $v->question_img ? "<img src='".$v->question_img."'>" : $v->question;?></h6>
                  <div class="test_question_textarea normal">
                     <textarea name="<?=$v->questionid?>" class="each_answer"></textarea>
                  </div>
               </div>
               <?php
               break;
            // make default to singleanswer
            default:
               ?>
               <div class="test_questionbox">
                  <h6><?=$k+1?>. <? echo $v->question_img ? "<img src='".$v->question_img."'>" : $v->question;?></h6>
                  <div class="test_question_select normal">
                     <?php foreach ($v->answer as $key => $choice):?>
                     <label class="radio">
                        <input type="radio" class="each_answer" name="<?=$v->questionid?>" value="<?=$key+1?>"/>
                        <?=$op_label[$key]?>. <?php echo htmlspecialchars($choice->choice);?>
                     </label>
                     <?php endforeach;?>
                  </div>
               </div>
               <?php
               break;
         }
         ?>
         <?php endforeach;?>
         </div>

         <div class="loadmorequstion yahei" id="loadmorequstion" style="display:none;">加载更多试题</div>

         <div class="ready_btn ready_btn_top">
            <input class="ppp_bluebtn ready_btn_width" id="paperSubmitbtn" style="margin:auto;<? echo $_['baseExamInfo']->count<=5 ? "" : "display:none;" ?>" type="submit" value="完成并提交" disabled="disabled"/>
            <input type="hidden" id="token" name="token" value="<?=$_['token']?>"/>
            <input type="hidden" name="employer_id" value="<?=$_['basicInfo']->employer_id?>"/>
            <input type="hidden" name="jobseeker_id" value="<?=$_['basicInfo']->jobseeker_id?>"/>
            <input type="hidden" id="jobid" name="job_id" value="<?=$_['basicInfo']->job_id?>"/>
            <input type="hidden" name="sheetid" value="<?=$_['baseExamInfo']->sheetid?>"/>
            <input type="hidden" name="session_id" value="0" id="session_id"/>
            <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            <div id='errormsg' class='error' style='margin-top: 10px; display:none; text-align:center;'></div>
         </div>
         </form>
         <div id="last_end" style="display:none;"><?=$_['examPaper']['last_end'];?></div>
         <div id="total_num" style="display:none;"><?=$_['baseExamInfo']->count?></div>
      </div>
   </div>
</div>
